import React, { PureComponent  } from 'react';
import {connect} from 'react-redux'
import {CartListStyled} from 'styled/Cart/CartListStyled.js'

import { Loading } from 'element-react';
import 'element-theme-default';

class CartList extends PureComponent  {
    constructor(props){
        super(props)
        this.state={
            arr:this.props.state.CR.get("cartData")
        }
    }
    

    
    render() {
        return (
            <CartListStyled>
                <h1>商品推荐</h1>
                <div>
                    {
                        
                        this.props.state.CR.get("cartData").length===0
                        ?<div className="el-loading-demo">
                            <Loading text="拼命加载中">
                            </Loading>
                        </div>
                        // ?<div></div>
                        :this.props.state.CR.get("cartData").map((v,i)=>{
                            return(
                                <dl key={v.id}>
                                    <dd>
                                        <img src={v.image} alt=""/>
                                    </dd>
                                    <dt>
                                        <p>{v.goods_name}</p>
                                        <h2><span>¥{v.price}</span><span>+{v.integral}</span>积分</h2>
                                        <h3>
                                            <span>{v.goods_subregion===1?"玖逗自营":'放心购'}</span>
                                            <b>已售{v.real_buy_count}</b>
                                        </h3>
                                    </dt>
                                </dl>
                            )
                        })
                    }
                </div>
            </CartListStyled>
        );
    }
}

export default connect((state)=>({state}))(CartList);